﻿@model FooterModel
@using Stores.Web.Models.Common;

<section id="footer" class="container">

    <div class="row">
        <div class="span1">

        </div>
        <div class="span10">
            <div class="x-first-col">
                <div class="row-fluid">
                    <nav class="footer-quicklinks service span12 first-col">
                        <h4>@T("Footer.Service")</h4>
                        <ul class="unstyled">
                            <li><a href="@Url.RouteUrl("Topic", new { SystemName = "shippinginfo" })">@T("ShippingReturns")</a></li>
                            <li><a href="@Url.RouteUrl("Topic", new { SystemName = "privacyinfo" })">@T("PrivacyNotice")</a></li>
                            <li><a href="@Url.RouteUrl("Topic", new { SystemName = "conditionsofUse" })">@T("ConditionsOfUse")</a></li>
                            @if (Model.Topics.ContainsKey("paymentinfo"))
                            {
                                <li><a href="@Url.RouteUrl("Topic", new { SystemName = "paymentinfo" })">@T("Paymentinfo")</a></li>
                            }
                        </ul>
                    </nav>

                    <nav class="footer-quicklinks company span12 first-col">
                        <h4>@T("Footer.Company")</h4>
                        <ul class="unstyled">
                            <li><a href="@Url.RouteUrl("ContactUs")">@T("ContactUs")</a> </li>
                            <li><a href="@Url.RouteUrl("Topic", new { SystemName = "aboutus" })">@T("AboutUs")</a></li>
                            @if (Model.Topics.ContainsKey("imprint")) {
                                <li><a href="@Url.RouteUrl("Topic", new { SystemName = "imprint" })">@T("Imprint")</a></li>
                            }
                            @if (Model.Topics.ContainsKey("disclaimer"))
                            {
                                <li><a href="@Url.RouteUrl("Topic", new { SystemName = "disclaimer" })">@T("Disclaimer")</a></li>
                            }
                            @if (Model.BlogEnabled)
                            {
                                <li><a href="@Url.RouteUrl("Blog")">@T("Blog")</a></li>
                            }
                            @if (Model.ForumEnabled)
                            {
                                <li><a href="@Url.RouteUrl("Boards")">@T("Forum.Forums")</a></li>
                            }
                        </ul>
                    </nav>
                </div>
            </div>
        </div>

        <div class="span8">
            
        </div>

    </div>

    <div class="row">
        <div class="span24">
            @Html.Widget("footer")
        </div>
    </div>
</section>

<div class="footer-disclaimer container clearfix">
    @if (Model.ShowLegalInfo) 
    {
        <div class="footer-legal pull-left">
            @Html.Raw(Model.LegalInfo)
        </div>
    }
    <div class="pull-right">@T("Content.CopyrightNotice", DateTime.Now.Year.ToString(), @Model.StoreName)</div>
</div>

<div id="switch-to-mobile">
    @Html.Action("ChangeDeviceBlock", "Common")
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $('#newsletter-subscribe-button').click(function () {
                
            var subscribe = 'true';
            if($('#newsletter-unsubscribe').is(':checked')) { 
                subscribe = 'false';
            }
            var email = $("#newsletter-email").val();
            
            $.ajax({
                cache: false,
                type: "POST",
                url: "@(Url.RouteUrl("SubscribeNewsletter"))",
                data: { "subscribe": subscribe, "email": email },
                success: function (data) {
                    $("#newsletter-result-block").html(data.Result);
                    if (data.Success) {
                        $('#newsletter-subscribe-block').hide();
                        $('#newsletter-result-block').removeClass("alert-error").addClass("alert-success").show();
                    }
                    else {
                        $('#newsletter-result-block').removeClass("alert-success").addClass("alert-error").fadeIn("slow").delay(2000).fadeOut("slow");
                    }
                },
                error:function (xhr, ajaxOptions, thrownError){
                    $("#newsletter-result-block").empty().text("Failed to subscribe").removeClass("alert-success").addClass("alert-error");
                }  
            });                
            return false;
        });

        if (Modernizr.touch) {
            $('#switch-to-mobile').css('display', 'block');
        }
    });
</script>